<?php
/**
 * Created by PhpStorm.
 * User: yyq
 * Date: 2018/7/4
 * Time: 15:56
 */

namespace Advertisement\Controller;


use Common\Controller\AdminbaseController;
use Common\Model\InfoTypeModel;

class InfoTypeController extends AdminbaseController
{
    private $info_type_model;

    public function __construct()
    {
        parent::__construct();
        $this->info_type_model  = new InfoTypeModel();
    }

    public function lists() {
        $result = $this->info_type_model->order('sort asc')->select();

        $this->assign('list', $result);
        $this->display();
    }

    public function add() {
        if($this->info_type_model->create()) {
            if($this->info_type_model->add()) {
                $this->success('操作成功');
            } else {
                $this->error('操作失败');
            }
        } else {
            $this->error($this->info_type_model->getDbError());
        }
    }

    public function edit() {
        $data = I('post.');
        if($this->info_type_model->save($data)) {
            $this->success('操作成功');
        } else {
            $this->error('操作失败');
        }

    }
}